/**
 * 	write on 2005-10-29 23:18:58.
 */
package org.nanhill.xmlro.srojs;

import org.nanhill.xmlro.Serializer;
import org.nanhill.xmlro.XmlroOutput;

/**
 * @author alin
 * 
 */
public class JavascriptLongArraySerializer implements Serializer {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.protocol.xmlro.Serializer#writeObject(java.lang.Object,
	 *      org.nanhill.protocol.xmlro.Output)
	 */
	public void writeObject(Object obj, XmlroOutput out) {
		long[] data = (long[]) obj;
		out.writeListBegin();
		int lastIndex = data.length - 1;
		for (int i = 0; i < data.length; i++) {
			out.writeLong(data[i]);
			if (i < lastIndex) {
				out.writeListElementSplit();
			}
		}
		out.writeListEnd();
	}

}
